-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for SNS topics #1952
Conversation
@@ -0,0 +1,104 @@ | |||
package aws |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this file should be actually called resource_
since it's not really a resource with its own schema.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. Easy fix. One moment.
This is a cut and dry resource addition with one exception: There's no way to describe or filter for a single topic in the AWS API. Callers must paginate their response every 100 topics, and match on a known ARN. So, implement an SNS topic seeker. This is a fairly simple state machine based on Rob Pike's "Lexical Scanning in Go" presentation: http://cuddle.googlecode.com/hg/talk/lex.html#title-slide
822e279
to
e23862a
Compare
Self-closing this in favor of #1974. It adds more support and uses a GetTopicAttributes call I wasn't aware of to better flesh out the topic's computed properties. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Chips away at #28. This would have been the simplest thing in the world to do were it not for one, uh, feature of the SNS API. There is no way to describe or filter for an individual topic.
Instead, you have to page results back from a complete topic list, and unlike autoscaling groups (whose paging limit is something like 1600), the paging limit for SNS topics is 100. I didn't feel right not supporting result paging here; it's entirely possible a TF user could have more than 100 SNS topics if they really love the product, so I wrote a pager.
The file is
sns_topic_seeker.go
and implements a basic state machine whose design will look mighty familiar if you've ever seen this presentation by Rob Pike or read the source code totext/template/parse/lex.go
in the stdlib. It's basically a slimmed down implementation of the same pattern, and I've covered it with a bunch of unit tests to make sure it works and works well.For what it's worth, I think it could be abstracted to an interface and used to "page" anything in AWS that returns a
NextToken
, but I didn't want to build a generalized version if this is the only AWS resource that'll use it.Anyway, let me know if there are any problems here. I'm going to add SNS topic support to AS groups too per #1419, but that file's a bit complex and I didn't feel like biting it off quite yet. I need it though so I'll try to finish it off later this week.